import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.*;

/**
 * This is a Pharmacist within the Hospital. They take care of providing 
 * prescriptions to the patients out of the hospital pharmacy.
 * @author Michael Zipp
 * @version 1.0
 */
public class Pharmacist extends User {
	private static Logger pharmacistLog = Logger.getLogger(Pharmacist.class.getName());
	
	/**
	 * Creates a new pharmacist user for the system.
	 * @param name Name of the pharmacist
	 * @param username User name for login
	 * @param password Password for login
	 * @param address Address of the pharmacist
	 * @param phoneNum Phone number of the pharmacist
	 * @param email Email address of the pharmacist
	 * @param age Age of the pharmacist
	 */
	
	static{
		ConsoleHandler console = new ConsoleHandler();
		console.setLevel(Level.ALL);
		console.setFormatter(new ThunderDragonHtmlFormatter());
		pharmacistLog.addHandler(console);
		pharmacistLog.setLevel(Level.ALL);
		
		try {
			FileHandler fh = new FileHandler("PharmacistLog.txt");
			fh.setFormatter(new ThunderDragonHtmlFormatter());
			pharmacistLog.addHandler(fh);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			pharmacistLog.severe("Failure: Security exception thrown" +
					" when trying to create a new handler " +
					"in Pharmacist.java.");
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			pharmacistLog.severe("Failure: I/O exception thrown" +
					" when trying to create a new handler" +
					" in Pharmacist.java.");
			e.printStackTrace();
		}
		
	}
	
	public Pharmacist(String name, String username, String password,
			String address, String phoneNum, String email, String age) {
		super(name, username, password, address, phoneNum, email, age);
		pharmacistLog.entering(this.getClass().getName(), 
				"Pharmacist Constructor", new Object[] {name, username,
			password, address, phoneNum, email, age});
		pharmacistLog.exiting(this.getClass().getName(), "Pharmacist Constructor");
		usertype = "pharm";
		
	}

	public Pharmacist() {
		super("name", "username", "password", "address", "phoneNum", "email", "20");
		pharmacistLog.entering(this.getClass().getName(), 
				"Pharmacist Default Constructor");
		pharmacistLog.exiting(this.getClass().getName(), 
				"Pharmaciest Default Constructor");
		
		usertype = "pharm";
	}
	
	/**
	 * Brings up a patients record for viewing
	 * @param patientName Name of the Patient
	 * @return The Medical Record of the patient
	 */
	public MedicalRecord viewReport(String patientName){
		pharmacistLog.finest("Called viewReport() in class Pharmacist.");
		return null;
		//Search for patient
		//If no patient found, display so.
		//If found, return that patients Medical Record
	}
	
	/**
	 * Views a patients information.
	 * @param patientUsername Username of the patient to be viewed.
	 * @return the Patient
	 */
	public Patient viewPatient(String patientUsername){
		ArrayList<Patient> results = 
			UserDatabase.searchPatient( patientUsername,
					UserDatabase.USERNAME_SEARCH);
		pharmacistLog.finest("Called viewPatient() in class Pharmacist.");
		return results.get(0);
	}

	@Override
	public String toString() {
		return "Pharmacist []";
	}
	
	
}
